package io.renren.com.qywt.excel.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class PayforResultConverter implements Converter<Integer> {
    @Override
    public Class<Integer> supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }
    @Override
    public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        if(cellData.getStringValue().equals("快递公司责任，赔偿")){
            return 0;
        }else if(cellData.getStringValue().equals("仓库责任，赔偿")){
            return 1;
        }else if(cellData.getStringValue().equals("其他赔偿方案")){
            return 2;
        }else if(cellData.getStringValue().equals("暂未定赔偿方案")){
            return 3;
        }else{
            return 4;
        }
    }

    @Override
    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        if(value == 0){
            return new WriteCellData<>("快递公司责任赔偿");
        }else if(value == 1){
            return new WriteCellData<>("仓库责任赔偿");
        }else if(value == 2){
            return new WriteCellData<>("其他赔偿方案");
        }else if(value == 3){
            return new WriteCellData<>("暂未定赔偿方案");
        }else{
            return new WriteCellData<>("要求与财务对账核实理赔");
        }
    }
}
